package com.yyysj.friend.controller;

import com.yyysj.common.core.domain.Result;
import com.yyysj.common.core.domain.TableDataInfo;
import com.yyysj.friend.domain.dto.QuestionQueryDTO;
import com.yyysj.friend.domain.vo.QuestionDetailVO;
import com.yyysj.friend.domain.vo.QuestionVO;
import com.yyysj.friend.service.IQuestionService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping("/question")
public class QuestionController {

    private final IQuestionService questionService;

    @GetMapping("/semiLogin/list")
    public TableDataInfo list(QuestionQueryDTO questionQueryDTO) {
//        List<QuestionVO> questionVOList = questionService.list(questionQueryDTO);
//        if (questionVOList == null || questionVOList.size() <= 0) {
//            return TableDataInfo.empty();
//        }
//        return TableDataInfo.success(questionVOList, questionVOList.size());
        return questionService.list(questionQueryDTO);
    }

    @GetMapping("/semiLogin/hotList")
    public Result<List<QuestionVO>> hotList() {
        return Result.ok(questionService.hotList());
    }

    @GetMapping("/detail")
    public Result<QuestionDetailVO> detail(Long questionId) {
        return Result.ok(questionService.detail(questionId));
    }

    @GetMapping("/preQuestion")
    public Result<String> preQuestion(Long questionId) {
        return Result.ok(questionService.preQuestion(questionId));
    }

    @GetMapping("/nextQuestion")
    public Result<String> nextQuestion(Long questionId) {
        return Result.ok(questionService.nextQuestion(questionId));
    }
}
